import { createRouter, createWebHashHistory } from "vue-router";

import baseRoutes from "./routes/routes";
const Base = () =>
  import(/* webpackChunkName: "Base" */ "@/layouts/base/base.vue");
const NotFound = () =>
  import(/* webpackChunkName: "NotFound" */ "@/layouts/404/404.vue");

const routes = [
  {
    path: "/",
    name: "Root",
    redirect: "/base",
    meta: {
      title: "",
      isKeepAlive: false,
    },
  },

  {
    path: "/base",
    name: "Base",
    component: Base,
    children: baseRoutes,
    redirect: "/dashboard",
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  // 加载所有路由
  routes,
});

router.beforeEach((to, from, next) => {
  document.title = to.meta.title as string;
  next();
});

export default router;
